package com.csdn;

public class Test4 {
    public static void main(String[] args) {
        Animals_ []animals=new Animals_[3];
        animals[0]=new Dog_();
        animals[1]=new Cat_();
        animals[2]=new Animals_();
        for(int i=0;i<animals.length;i++){
            animals[i].eat();
        }
    }
}

class Animals_{
    public void eat(){
        System.out.println("动物吃...");
    }
}
class Dog_ extends Animals_{
    @Override
    public void eat() {
        System.out.println("小狗吃狗粮");
    }
}

class Cat_ extends Animals_{
    @Override
    public void eat() {
        System.out.println("小猫吃猫粮");
    }
}
